/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.casestudy1.bus;

import com.casestudy1.main.MainMidlet;
import com.casestudy1.view.LinearGradientPainter;
import com.sun.lwuit.Button;
import com.sun.lwuit.CheckBox;
import com.sun.lwuit.ComboBox;
import com.sun.lwuit.Form;
import com.sun.lwuit.Label;
import com.sun.lwuit.TextArea;
import com.sun.lwuit.TextField;
import com.sun.lwuit.animations.CommonTransitions;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BoxLayout;
import com.sun.lwuit.plaf.Style;

/**
 *
 * @author PC
 */
public class SearchNumber extends Form{
    private Label lbNumber;
    private Label lbResult;
    private ComboBox cbbNumber;
    private TextField txtNumber;
    private TextArea taResult;
    private CheckBox cbDetail;
    private Button btSearch;
    private Button btClear;
    private Button btBack;
    
    public SearchNumber(final MainMidlet midlet){
        super("Tim kiem");
        Style titlestyle = new Style();
        titlestyle.setAlignment(CENTER);
        titlestyle.setBgPainter(new LinearGradientPainter(0, 0xffffff, false));
        setTitleStyle(titlestyle);
        getStyle().setBgPainter(new LinearGradientPainter( 0x330000, 0xFF0000, false));
        setLayout(new BoxLayout(BoxLayout.Y_AXIS));

        setTransitionOutAnimator(CommonTransitions.createSlide(
                CommonTransitions.SLIDE_HORIZONTAL, true, 1000));
        
        lbNumber = new Label("So xe :");
        lbResult = new Label("Ket qua :");
        
        taResult = new TextArea(4, CENTER);
        cbbNumber = new ComboBox();
        for(int i = 1; i<60 ; i++){
            if(i<10){
                cbbNumber.addItem("Bus 0" +i);
            }else{
                cbbNumber.addItem("Bus " +i);
            }
        }
        cbbNumber.setHeight(5);
        cbDetail = new CheckBox("Chi tiet");
        cbDetail.setAlignment(LEFT);
        
        btSearch = new Button("Tim Kiem");
        btClear = new Button("Xoa");
        btClear.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent ae) {
                if(txtNumber.getText().equals("")|| taResult.getText().equals("")){
                    txtNumber.setText(null);
                    taResult.setText(null);
                }
            }
        });
        btBack = new Button("Quay lai");
        btBack.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent ae) {
                midlet.showSearchBus();
            }
        });
        
        addComponent(lbNumber);
        addComponent(cbbNumber);
        addComponent(lbResult);
        addComponent(taResult);
        addComponent(cbDetail);
        addComponent(btSearch);
        addComponent(btClear);
        addComponent(btBack);
    }
}
